home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / mac / PageMaker 6.5 SDK Mac / SourceCode / C_Language / Frame / Common / MAIN.CPP
C/C++ Source or Header  |  1996-07-16  |  7KB  |  293 lines

  1. /*
  2.  *--- main.cpp ----------------------------------------------------------
  3.  * Copyright (c) 1992-96 Adobe Systems, Inc.  All rights reserved.
  4.  *
  5.  * PageMaker plug-in OpenCopy.
  6.  *-----------------------------------------------------------------------
  7.  */
  8.  
  9. /* ---------------- PageMaker SDK include files ---------------- */
  10. #include "PMPlugin.h"
  11.  
  12. /* ---------------- Plug-in include files ---------------- */
  13. #ifdef MACINTOSH
  14.     #include "WinTypes.h"
  15. #endif // MACINTOSH
  16.  
  17. /* ---------------- Cross-platform include files ---------------- */
  18. #include <string.h>
  19. #include <stdio.h>
  20.  
  21. /* ---------------- Platform specific include files ---------------- */
  22. #ifdef MACINTOSH
  23.     #include <types.h>
  24.     #ifndef powerc
  25.         #include <A4Stuff.h>
  26.         #include <SetUpA4.h>
  27.     #endif
  28. #else
  29.     #include <windows.h>
  30. #endif
  31.  
  32. /* ---------------- Type definitions ---------------- */
  33.  
  34. /* ---------------- Definitions ---------------- */
  35. #define SUCCESS            1
  36. #define FAILURE            0
  37. #define STAYINMEMORY    -1
  38.  
  39. /* ---------------- PageMaker (New)SDK include files ---------------- */
  40. #include "CIInterfaceManager.h"
  41. #include "PMEvent.h"
  42. #include "PMEventRec.h"
  43. #include "CIBasic.h"
  44. #include "PMInterfaceIDs.h"
  45. #include "CICommandsAndQueries.h"
  46.  
  47. /* ---------------- Function declarations ---------------- */
  48. PMXErr DoInvoke( PMMessage *pMsg );
  49. PMXErr DoLoad(PMMessage* pMsg);
  50. PMXErr DoRegister(PMMessage* pMsg);
  51. PMXErr DoInvoke(PMMessage* pMsg);
  52. PMXErr DoEvent(PMMessage* pMsg);
  53. PMXErr DoSysEvent(PMMessage* pMsg);
  54. PMXErr DoAcquireInterface(PMMessage* pMsg);
  55. PMXErr DoReleaseInterface( PMMessage *pMsg );
  56. PMXErr DoUnload(PMMessage* pMsg);
  57. PMXErr DoShutdown(PMMessage* pMsg);
  58. PMXErr DoCleanup(PMMessage* pMsg);
  59.  
  60. #ifdef MACINTOSH
  61.     #ifdef powerc
  62.         #pragma export on
  63.     #endif
  64.         PMXErr main(PMMessage *pMsg);
  65.     #ifdef powerc
  66.         #pragma export off
  67.     #endif
  68. #else
  69.     BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID pReserved);
  70. #endif
  71.  
  72. /* ---------------- Globals ---------------- */
  73. sPMParamBlockPtr thePB = NULL;
  74. CIInterfaceManager    *gpIntfMgr = (CIInterfaceManager *) NULL;
  75.  
  76. #ifdef WINDOWS
  77.     HINSTANCE ghDLL;
  78.  
  79. BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID pReserved)
  80. {
  81.     ghDLL = hDLL;
  82.  
  83.     return TRUE;
  84. }
  85. #endif
  86.  
  87. /*
  88.  *--- main --------------------------------------------------------------------
  89.  *  Entry point for plug-in control tasks.
  90.  *-----------------------------------------------------------------------------
  91.  */ 
  92. PMXErr main(PMMessage *pMsg)
  93. {
  94.     PMXErr    result;
  95. #if __MWERKS__ && __MC68K__
  96.     long oldA4 = SetCurrentA4();
  97.     RememberA4();
  98. #endif
  99.  
  100.     gpIntfMgr = pMsg->pInterfaceMgr;
  101.     
  102.     switch ( pMsg->opCode ) {
  103.         case kPMLoad: 
  104.             result = DoLoad(pMsg);
  105.             break;
  106.  
  107.         case kPMRegister: 
  108.             result = DoRegister(pMsg);
  109.             break;
  110.             
  111.         case kPMInvoke: 
  112.             result = DoInvoke(pMsg);
  113.             break;
  114.  
  115.         case kPMEvent: 
  116.             result = DoEvent(pMsg);
  117.             break;
  118.             
  119.         case kPMSysEvent: 
  120.             result = DoSysEvent(pMsg);
  121.             break;
  122.             
  123.         case kPMAcquireInterface: 
  124.             result = DoAcquireInterface(pMsg);
  125.             break;
  126.             
  127.         case kPMReleaseInterface: 
  128.             result = DoReleaseInterface(pMsg);
  129.             break;
  130.             
  131.         case kPMUnload: 
  132.             result = DoUnload(pMsg);
  133.             break;
  134.  
  135.         case kPMShutdown: 
  136.             result = DoShutdown(pMsg);
  137.             break;
  138.             
  139.         case kPMCleanup: 
  140.             result = DoCleanup(pMsg);
  141.             break;
  142.             
  143.         default: 
  144.             result = 0;
  145.     }
  146.  
  147. #if __MWERKS__ && __MC68K__
  148.     SetA4(oldA4);
  149. #endif
  150.  
  151.     return result;
  152. }
  153.  
  154. /*
  155.  *--- DoRegister --------------------------------------------------------------
  156.  *  Called if Plug-in registers for Events or adds new interfaces to PM.
  157.  *-----------------------------------------------------------------------------
  158.  */ 
  159. PMXErr DoRegister( PMMessage *pMsg )
  160. {
  161.     PMXErr     result = SUCCESS;
  162.  
  163.     gpIntfMgr = pMsg->pInterfaceMgr;
  164.  
  165.     return result;
  166. }
  167.  
  168. /*
  169.  *--- DoAcquireInterface ------------------------------------------------------
  170.  *  Called when other plug-ins acquire the exported interface.
  171.  *-----------------------------------------------------------------------------
  172.  */ 
  173. PMXErr DoAcquireInterface( PMMessage *pMsg )
  174. {
  175.     PMXErr result = SUCCESS;
  176.  
  177.     gpIntfMgr = pMsg->pInterfaceMgr;
  178.  
  179.     return result;
  180. }
  181.  
  182. /*
  183.  *--- DoReleaseInterface ------------------------------------------------------
  184.  *  Called when other plug-ins release the acquired interface.
  185.  *-----------------------------------------------------------------------------
  186.  */ 
  187. PMXErr DoReleaseInterface( PMMessage *pMsg )
  188. {
  189.     PMXErr result = SUCCESS;
  190.  
  191.     gpIntfMgr = pMsg->pInterfaceMgr;
  192.             
  193.     return result;
  194. }
  195.  
  196. /*
  197.  *--- DoInvoke ----------------------------------------------------------------
  198.  *  
  199.  *-----------------------------------------------------------------------------
  200.  */ 
  201. PMXErr DoInvoke( PMMessage *pMsg )
  202. {
  203.     PMXErr result = SUCCESS;
  204.  
  205.     gpIntfMgr = pMsg->pInterfaceMgr;
  206.  
  207.     return result;
  208. }
  209.  
  210. /*
  211.  *--- DoLoad ------------------------------------------------------------------
  212.  *  
  213.  *-----------------------------------------------------------------------------
  214.  */ 
  215. PMXErr DoLoad(PMMessage* pMsg)
  216. {
  217.     PMXErr     result = SUCCESS;
  218.  
  219.     gpIntfMgr = pMsg->pInterfaceMgr;
  220.  
  221.     return result;
  222. }
  223.  
  224. /*
  225.  *--- DoEvent -----------------------------------------------------------------
  226.  *  
  227.  *-----------------------------------------------------------------------------
  228.  */ 
  229. PMXErr DoEvent(PMMessage* pMsg)
  230. {
  231.     PMXErr     result = SUCCESS;
  232.  
  233.     gpIntfMgr = pMsg->pInterfaceMgr;
  234.  
  235.     return result;
  236. }
  237.  
  238. /*
  239.  *--- DoSysEvent --------------------------------------------------------------
  240.  *  
  241.  *-----------------------------------------------------------------------------
  242.  */ 
  243. PMXErr DoSysEvent(PMMessage* pMsg)
  244. {
  245.     PMXErr     result = SUCCESS;
  246.  
  247.     gpIntfMgr = pMsg->pInterfaceMgr;
  248.  
  249.     return result;
  250. }
  251.  
  252. /*
  253.  *--- DoUnload ----------------------------------------------------------------
  254.  *  
  255.  *-----------------------------------------------------------------------------
  256.  */ 
  257. PMXErr DoUnload(PMMessage* pMsg)
  258. {
  259.     PMXErr     result = SUCCESS;
  260.  
  261.     gpIntfMgr = pMsg->pInterfaceMgr;
  262.  
  263.     return result;
  264. }
  265.  
  266. /*
  267.  *--- DoShutdown --------------------------------------------------------------
  268.  *  
  269.  *-----------------------------------------------------------------------------
  270.  */ 
  271. PMXErr DoShutdown(PMMessage* pMsg)
  272. {
  273.     PMXErr     result = SUCCESS;
  274.  
  275.     gpIntfMgr = pMsg->pInterfaceMgr;
  276.  
  277.     return result;
  278. }
  279.  
  280. /*
  281.  *--- DoCleanup ---------------------------------------------------------------
  282.  *  
  283.  *-----------------------------------------------------------------------------
  284.  */ 
  285. PMXErr DoCleanup(PMMessage* pMsg)
  286. {
  287.     PMXErr     result = SUCCESS;
  288.  
  289.     gpIntfMgr = pMsg->pInterfaceMgr;
  290.  
  291.     return result;
  292. }
  293.